import akshare as ak
import pandas

def get_zh_stock_index_spot(symbol: str):
    stock_df = ak.stock_zh_index_spot(symbol)
    if stock_df is not None:
        return stock_df
    else:
        return None


def get_zh_stock_index_daily_history(symbol: str):
    try:
        history_daily = ak.stock_zh_index_daily(symbol)
    except:
        try:
            history_daily = ak.stock_zh_index_daily_tx(symbol)
        except:
            history_daily = ak.stock_zh_index_daily_em(symbol)
    if history_daily is not None:
        return history_daily
    else:
        return None



if __name__ == "__main__":
    stock_df = get_zh_stock_index_spot()
    print(stock_df)
    stock_df.to_csv("stock_index_spot.csv")